import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    listArr: [],
  },

  getters: {
    weiwancheng(state) {
      let arr = state.listArr.filter((item) => {
        return item.status == false
      })
      return arr.length
    }
  },

  mutations: {
    jiaru(state, value) {
      var obj = { id: state.listArr.length + 1, name: value, status: false };
      // state.listArr.push(obj)
      state.listArr.push(obj)
    },
    fanhui(state, value) {
      let f1 = state.listArr.find((item) => {
        return item.id == value.id
      })

      if (f1) {
        f1.status = !f1.status

      }
    },
    clear_gogo(state, value) {
      state.listArr.splice(value, 1)
    }
  },

  actions: {

  },
  modules: {

  }
})
